{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "#load \"..\\Extension\\LoadBaseTool.csx\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## `DateTime`格式化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ ]-2024/10/18 9:15:44\n",
      "[d]-2024/10/18\n",
      "[D]-2024年10月18日\n",
      "[f]-2024年10月18日 9:15\n",
      "[F]-2024年10月18日 9:15:44\n",
      "[g]-2024/10/18 9:15\n",
      "[G]-2024/10/18 9:15:44\n",
      "[t]-9:15\n",
      "[T]-9:15:44\n",
      "[u]-2024-10-18 09:15:44Z\n",
      "[U]-2024年10月18日 1:15:44\n",
      "[m]-10月18日\n",
      "[M]-10月18日\n",
      "[r]-Fri, 18 Oct 2024 09:15:44 GMT\n",
      "[R]-Fri, 18 Oct 2024 09:15:44 GMT\n",
      "[y]-2024年10月\n",
      "[Y]-2024年10月\n",
      "[o]-2024-10-18T09:15:44.9919766+08:00\n",
      "[O]-2024-10-18T09:15:44.9920064+08:00\n",
      "[s]-2024-10-18T09:15:44\n",
      "2024-10-18 09:15:44.99\n"
     ]
    }
   ],
   "source": [
    "\n",
    "Console.WriteLine($\"[ ]-{DateTime.Now.ToString()}\");\n",
    "Console.WriteLine($\"[d]-{DateTime.Now.ToString(\"d\")}\");\n",
    "Console.WriteLine($\"[D]-{DateTime.Now.ToString(\"D\")}\");\n",
    "Console.WriteLine($\"[f]-{DateTime.Now.ToString(\"f\")}\");\n",
    "Console.WriteLine($\"[F]-{DateTime.Now.ToString(\"F\")}\");\n",
    "Console.WriteLine($\"[g]-{DateTime.Now.ToString(\"g\")}\");\n",
    "Console.WriteLine($\"[G]-{DateTime.Now.ToString(\"G\")}\");\n",
    "Console.WriteLine($\"[t]-{DateTime.Now.ToString(\"t\")}\");\n",
    "Console.WriteLine($\"[T]-{DateTime.Now.ToString(\"T\")}\");\n",
    "Console.WriteLine($\"[u]-{DateTime.Now.ToString(\"u\")}\");\n",
    "Console.WriteLine($\"[U]-{DateTime.Now.ToString(\"U\")}\");\n",
    "Console.WriteLine($\"[m]-{DateTime.Now.ToString(\"m\")}\");\n",
    "Console.WriteLine($\"[M]-{DateTime.Now.ToString(\"M\")}\");\n",
    "Console.WriteLine($\"[r]-{DateTime.Now.ToString(\"r\")}\");\n",
    "Console.WriteLine($\"[R]-{DateTime.Now.ToString(\"R\")}\");\n",
    "Console.WriteLine($\"[y]-{DateTime.Now.ToString(\"y\")}\");\n",
    "Console.WriteLine($\"[Y]-{DateTime.Now.ToString(\"Y\")}\");\n",
    "Console.WriteLine($\"[o]-{DateTime.Now.ToString(\"o\")}\");\n",
    "Console.WriteLine($\"[O]-{DateTime.Now.ToString(\"O\")}\");\n",
    "Console.WriteLine($\"[s]-{DateTime.Now.ToString(\"s\")}\");\n",
    "Console.WriteLine(DateTime.Now.ToString(\"yyyy-MM-dd HH:mm:ss.ff\"));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[F]-2024年10月18日 9:15:45\n",
      "[g]-2024/10/18 9:15\n",
      "[G]-2024/10/18 9:15:45\n",
      "[t]-9:15\n",
      "[T]-9:15:45\n",
      "[u]-2024-10-18 09:15:45Z\n",
      "[U]-2024年10月18日 1:15:45\n",
      "[m]-10月18日\n",
      "[M]-10月18日\n",
      "[r]-Fri, 18 Oct 2024 09:15:45 GMT\n",
      "[R]-Fri, 18 Oct 2024 09:15:45 GMT\n",
      "[y]-2024年10月\n",
      "[Y]-2024年10月\n",
      "[o]-2024-10-18T09:15:45.3173334+08:00\n",
      "[O]-2024-10-18T09:15:45.3173674+08:00\n",
      "[s]-2024-10-18T09:15:45\n",
      "2024-10-18 09:15:45.31\n"
     ]
    }
   ],
   "source": [
    "Console.WriteLine($\"[F]-{DateTime.Now.ToString(\"F\")}\");\n",
    "Console.WriteLine($\"[g]-{DateTime.Now.ToString(\"g\")}\");\n",
    "Console.WriteLine($\"[G]-{DateTime.Now.ToString(\"G\")}\");\n",
    "Console.WriteLine($\"[t]-{DateTime.Now.ToString(\"t\")}\");\n",
    "Console.WriteLine($\"[T]-{DateTime.Now.ToString(\"T\")}\");\n",
    "Console.WriteLine($\"[u]-{DateTime.Now.ToString(\"u\")}\");\n",
    "Console.WriteLine($\"[U]-{DateTime.Now.ToString(\"U\")}\");\n",
    "Console.WriteLine($\"[m]-{DateTime.Now.ToString(\"m\")}\");\n",
    "Console.WriteLine($\"[M]-{DateTime.Now.ToString(\"M\")}\");\n",
    "Console.WriteLine($\"[r]-{DateTime.Now.ToString(\"r\")}\");\n",
    "Console.WriteLine($\"[R]-{DateTime.Now.ToString(\"R\")}\");\n",
    "Console.WriteLine($\"[y]-{DateTime.Now.ToString(\"y\")}\");\n",
    "Console.WriteLine($\"[Y]-{DateTime.Now.ToString(\"Y\")}\");\n",
    "Console.WriteLine($\"[o]-{DateTime.Now.ToString(\"o\")}\");\n",
    "Console.WriteLine($\"[O]-{DateTime.Now.ToString(\"O\")}\");\n",
    "Console.WriteLine($\"[s]-{DateTime.Now.ToString(\"s\")}\");\n",
    "Console.WriteLine(DateTime.Now.ToString(\"yyyy-MM-dd HH:mm:ss.ff\"));"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## `DateOnly` 和 `TimeOnly`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024年10月18日 0:00:00\n",
      "2024/10/18\n",
      "292\n",
      "2024年10月18日 9:15:45\n",
      "9:15\n"
     ]
    }
   ],
   "source": [
    "DateOnly _date_only = DateOnly.FromDateTime(DateTime.Today);\n",
    "\n",
    "Console.WriteLine($\"{DateTime.Today:F}\");\n",
    "Console.WriteLine($\"{_date_only}\");  // Date Only 没法使用格式化\n",
    "Console.WriteLine($\"{_date_only.DayOfYear}\");\n",
    "\n",
    "\n",
    "TimeOnly _time_only = TimeOnly.FromDateTime(DateTime.Now);\n",
    "Console.WriteLine($\"{DateTime.Now:F}\");\n",
    "Console.WriteLine($\"{_time_only}\");  // Time Only 没法使用格式化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World\r\n"
     ]
    }
   ],
   "source": [
    "Task _task = Task.Run(()=>{Console.WriteLine(\"Hello World\");});"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
